home *** CD-ROM | disk | FTP | other *** search
- /* Small Systems Guild */
- /* PO box 2751 */
- /* 3105 Sunnywood */
- /* Ann Arbor, Michigan 48103 */
- /* (313) 996-4238 */
-
- /* copyright © 1987 Small Systems Guild */
-
- /* source code compilable using */
- /* Lightspeed C compiler 2.01 */
-
- #include "objectMgr.h"
-
- Handle Object(sel,arg)
- USHORT sel;
- ULONG arg;
- {
- switch(sel) {
- case NEW: /* MUST be unique for each subclass */
- return(new_object());
- break;
- case SELF:
- return(self_object(arg));
- break;
- case CLASS:
- return(class_object(arg));
- break;
- case SIZE:
- return(size_object(arg));
- break;
- case ASK_STATUS:
- return(ask_object(arg));
- break;
- case SET_STATUS:
- return(set_object(arg));
- break;
- case VALID:
- return(valid_object(arg));
- break;
- case FREE:
- return(free_object(arg));
- break;
- default:
- return(NULL);
- }
- }
-
- Handle new_object()
- {
- Handle objHndl;
- ULONG size;
-
- size = (ULONG)sizeof(object);
- objHndl = NewHandle(size);
- if (!ValidHandle(objHndl))
- return(NULL);
- (**((object **)objHndl)).isa = OBJECT;
- (**((object **)objHndl)).size = size;
- (**((object **)objHndl)).status = INACTIVE;
- (**((object **)objHndl)).sync = OBJ_SYNC;
- (**((object **)objHndl)).id = objHndl;
- return(objHndl);
- }
-
- Handle self_object(objHndl)
- Handle objHndl;
- {
-
- if (!ValidHandle(objHndl))
- return(NULL);
-
- return(objHndl);
- }
-
- Handle class_object(objHndl)
- Handle objHndl;
- {
-
- if (!ValidHandle(objHndl))
- return(NULL);
-
- return((Handle)(**((object **)objHndl)).isa);
- }
-
- Handle size_object(objHndl)
- Handle objHndl;
- {
-
- if (!ValidHandle(objHndl))
- return(NULL);
-
- return((Handle)((**((object **)objHndl)).size));
- }
-
- Handle ask_object(objHndl)
- Handle objHndl;
- {
-
- if (!ValidHandle(objHndl))
- return(NULL);
-
- return((Handle)((**((object **)objHndl)).status));
- }
-
- Handle set_object(argPtr)
- Ptr argPtr;
- {
- Handle objHndl;
- ULONG objData;
-
- if (!ValidPointer(argPtr))
- return(NULL);
-
- objHndl = ((msgArgs *)argPtr)->objHndl;
- objData = ((msgArgs *)argPtr)->objDat1;
-
- if (!ValidHandle(objHndl))
- return(NULL);
-
- if (objData < INACTIVE || objData > DAMAGED)
- return(NULL);
-
- (**((object **)objHndl)).status = (USHORT)objData;
- return(objHndl);
- }
-
- Handle valid_object(objHndl)
- Handle objHndl;
- {
-
- if (!ValidHandle(objHndl))
- return(NULL);
-
- if (((**((object **)objHndl)).sync == OBJ_SYNC))
- return(objHndl);
- else
- return(NULL);
- }
-
- Handle free_object(objHndl)
- Handle objHndl;
- {
-
- if (!ValidHandle(objHndl))
- return(objHndl);
-
- if ((**((object **)objHndl)).status == ACTIVE)
- return(objHndl);
-
- DisposHandle(objHndl);
- return(NULL);
- }
-
-